home *** CD-ROM | disk | FTP | other *** search
/ World of Amiga / World of Amiga.iso / archive / assembly / mousereader.lha / moving-mouse.S < prev   
Text File  |  1987-01-01  |  1KB  |  91 lines

  1. ; MOVING-MOUSE
  2. main:
  3. bsr    mouse
  4.  
  5. lea.l    mousex,a1
  6. lea.l    mousey,a2
  7.  
  8. move.w    (a1),d1
  9. move.w    (a2),d2
  10.  
  11.  
  12.  
  13. btst    #6,$bfe001
  14. bne    main
  15. rts
  16.  
  17.  
  18. mouse:
  19. movem.l    d0-d7/a0-a6,-(a7)
  20. move.w    $dff00a,d0
  21. andi.l    #255,d0
  22. moveq    #0,d2
  23. move.l    #639,d3
  24. lea.l    oldx,a1
  25. lea.l    mousex,a2
  26. bsr.s    calcmouse
  27. move.w    $dff00a,d0
  28. lsr.w    #8,d0
  29. andi.l    #255,d0
  30. moveq    #0,d2
  31. move.l    #511,d3
  32. lea.l    oldy,a1
  33. lea.l    mousey,a2
  34. bsr.s    calcmouse
  35. movem.l    (a7)+,d0-d7/a0-a6
  36. rts
  37. calcmouse:
  38. moveq    #0,d1
  39. move.w    (a1),d1
  40. move.w    d0,(a1)
  41. move.l    d0,d5
  42. move.l    d1,d6
  43. sub.w    d0,d1
  44. cmp.w    #-128,d1
  45. blt.s    mc_less
  46. cmp.w    #127,d1
  47. bgt.s    mc_more
  48. cmp.w    #0,d1
  49. blt.s    mc_chk2
  50. mc_chk1:
  51. cmp.w    d5,d6
  52. bge.s    mc_chk1ok
  53. neg.w    d1
  54. mc_chk1ok:
  55. bra.s    mc_storem
  56. mc_chk2:
  57. cmp.w    d5,d6
  58. ble.s    mc_chk2ok
  59. neg.w    d1
  60. mc_chk2ok:
  61. bra.s    mc_storem
  62. mc_less:
  63. add.w    #256,d1
  64. bra.s    mc_storem
  65. mc_more:
  66. sub.w    #256,d1
  67. mc_storem:
  68. neg.w    d1
  69. add.w    d1,(a2)
  70. move.w    (a2),d0
  71. cmp.w    d2,d0
  72. blt.s    mc_toosmall
  73. cmp.w    d3,d0
  74. bgt.s    mc_toolarge
  75. rts
  76. mc_toosmall:
  77. move.w    d2,(a2)
  78. rts
  79. mc_toolarge:
  80. move.w    d3,(a2)
  81. rts
  82. oldx:
  83. dc.l    $0000
  84. oldy:
  85. dc.l    $0000
  86. mousex:
  87. dc.w    $0000
  88. mousey:
  89. dc.w    $0000
  90.  
  91.